<admintpl file="header" />
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
    .label-td {
        position: relative;
    }
    .label-td .label-container {
        float: left;
        width: 93%;
        overflow: hidden;
        white-space: nowrap;
    }
    .label-td .label-select {
        float: right;
        font-size: 18px;
        display: inline-block;
        position: relative;
        padding-top: 10px;
    }
    .label-td .label-select:hover {
        color: #5bc0de;
    }
    .label-td .label-container span {
        display: inline-block;
        width: 80px;
        height: 30px;
        line-height: 30px;
        border: 1px solid #5bc0de;
        border-radius: 10px;
        text-align: center;
        margin-right: 10px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
</style>
</head>
<body>
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="active">专栏作者信息</li>
        </ul>
        <div class="row-fluid">

            <form action="{:U('AdminProfessor/update_pf_info')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
                <div class="span9">

                    <input type="hidden" name="pf_info[id]" value="{$pf_info.id}">
                    <table class="table table-bordered">
                        <tr>
                            <th width="80">用户名</th>
                            <td>
                                {$user_info['user_nicename']}
                            </td>
                        </tr>
                        <tr>
                            <th width="80">职位</th>
                            <td>
                                {$user_info['position']}
                            </td>
                        </tr>
                        <tr>
                            <th width="80">公司</th>
                            <td>
                                {$user_info['company']}
                            </td>
                        </tr>
                        <tr>
                            <th width="80">婚姻</th>
                            <td>
                                <input type="radio" name="marry" value="1" {$user_info['marry'] == 1 ? 'checked' : ''}> 已婚
                                <input type="radio" name="marry" value="0" {$user_info['marry'] == 0 ? 'checked' : ''}> 未婚
                            </td>
                        </tr>
                        <tr>
                            <th width="80">简介</th>
                            <td>
                                <textarea style="width: 80%;">{$user_info['signature']}</textarea>
                            </td>
                        </tr>
                        <tr>
                            <th>标签</th>
                            <td class="label-td">
                                <div class="label-container">
                                    <input type="hidden" value="{$pf_info['labels']}" id="labels" name="pf_info[labels]">
                                    <volist name="pf_info[label_names]" id="vo">
                                        <span class="label-name">{$vo}</span>
                                    </volist>
                                </div>
                                <div class="label-select">
                                    <span class="label-select-span">选择标签</span>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th width="80">详细信息</th>
                            <td>
                                <textarea style="width: 80%;height: 200px;">{$pf_info['introduction']}</textarea>
                            </td>
                        </tr>

                        <tr>
                            <th width="80">项目信息</th>
                            <td>
                                <table class="table table-bordered">
                                    <td>ID</td>
                                    <td>项目名称</td>
                                    <td>开始时间</td>
                                    <td>结束时间</td>
                                    <td>项目简介</td>
                                    <foreach name="pf_projects" item="vo">
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.project_name}</td>
                                            <td>{$vo.start_time}</td>
                                            <td>{$vo.end_time|default="至今"}</td>
                                            <td><a href="javascript:void(0);" onclick="show_detail('项目介绍', '{$vo.project_desc}')">查看简介</a></td>
                                        </tr>
                                    </foreach>
                                </table>
                            </td>
                        </tr>


                        <tr>
                            <th width="80">教育经历</th>
                            <td>
                                <table class="table table-bordered">
                                    <td>ID</td>
                                    <td>学校名称</td>
                                    <td>开始时间</td>
                                    <td>结束时间</td>
                                    <td>专业</td>
                                    <td>学位</td>
                                    <foreach name="pf_education" item="vo">
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.school}</td>
                                            <td>{$vo.start_time}</td>
                                            <td>{$vo.end_time|default="至今"}</td>
                                            <td>{$vo.major}</td>
                                            <td>{$vo.degree}</td>
                                        </tr>
                                    </foreach>
                                </table>
                            </td>
                        </tr>

                        <tr>
                            <th width="80">出版作品</th>
                            <td>
                                <table class="table table-bordered">
                                    <td>ID</td>
                                    <td>作品名称</td>
                                    <td>出版刊物</td>
                                    <td>出版时间</td>
                                    <td>出版社</td>
                                    <foreach name="pf_publish" item="vo">
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.article_name}</td>
                                            <td>{$vo.magazine}</td>
                                            <td>{$vo.publish_time}</td>
                                            <td>{$vo.publish_house}</td>
                                        </tr>
                                    </foreach>
                                </table>
                            </td>
                        </tr>

                        <tr>
                            <th width="80">资格认证</th>
                            <td>
                                <table class="table table-bordered">
                                    <td>ID</td>
                                    <td>认证名称</td>
                                    <td>证书编号</td>
                                    <td>开始时间</td>
                                    <td>结束时间</td>
                                    <td>认证机构</td>
                                    <foreach name="pf_certificate" item="vo">
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.certificate_name}</td>
                                            <td>{$vo.certificate_no}</td>
                                            <td>{$vo.start_ime}</td>
                                            <td>{$vo.end_time}</td>
                                            <td>{$vo.certification}</td>
                                        </tr>
                                    </foreach>
                                </table>
                            </td>
                        </tr>


                        <tr>
                            <th width="80">专利发明</th>
                            <td>
                                <table class="table table-bordered">
                                    <td>ID</td>
                                    <td>专利名称</td>
                                    <td>专利国家</td>
                                    <td>专利号</td>
                                    <td>申请时间</td>
                                    <foreach name="pf_patent" item="vo">
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.patent_name}</td>
                                            <td>{$vo.patent_country}</td>
                                            <td>{$vo.patent_no}</td>
                                            <td>{$vo.patent_time}</td>
                                        </tr>
                                    </foreach>
                                </table>
                            </td>
                        </tr>

                        <tr>
                            <th width="80">荣誉奖项</th>
                            <td>
                                <table class="table table-bordered">
                                    <td>ID</td>
                                    <td>奖项名称</td>
                                    <td>颁奖机构</td>
                                    <td>获奖时间</td>
                                    <td>奖项说明</td>
                                    <foreach name="pf_award" item="vo">
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.award_name}</td>
                                            <td>{$vo.award_organization}</td>
                                            <td>{$vo.award_time}</td>
                                            <td><a href="javascript:void(0);" onclick="show_detail('奖项说明', '{$vo.award_desc}')">查看说明</a></td>
                                        </tr>
                                    </foreach>
                                </table>
                            </td>
                        </tr>
                    </table>

                    <div class="form-actions">
                        <button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
                        <a class="btn" href="javascript:window.history.go(-1);">返回</a>
                    </div>
                </div>

                <div class="span3">
                    <table class="table table-bordered">
                        <tr>
                            <th><b>粉丝群二维码</b></th>
                        </tr>
                        <tr>
                            <td>
                                <div style="text-align: center;">
                                    <input type="hidden" name="pf_info[fans_qrcode]" id="thumb" value="">
                                    <a href="javascript:upload_one_image('图片上传','#thumb');">
                                        <if condition="empty($pf_info['fans_qrcode'])">
                                            <img src="__TMPL__Public/assets/images/default-thumbnail.png" id="thumb-preview" width="135" style="cursor: hand" />
                                        <else />
                                            <img src="{:sp_get_image_preview_url($pf_info['fans_qrcode'])}" id="thumb-preview" width="135" style="cursor: hand"/>
                                        </if>
                                    </a>
                                    <input type="button" class="btn btn-small" onclick="$('#thumb-preview').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;" value="取消图片">
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>

            </form>
        </div>
    </div>
    <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/layer/layer_1.js"></script>
    <script>

        $('.label-select-span').click(function () {
            var has_labels = $('#labels').val();
            layer.open({
                title: "选择标签",
                type: 2,
                area: ['70%', '70%'],
                btn: ['确定', '取消'],
                content: "{:U('Label/AdminIndex/select_label')}" + "&has_labels=" + has_labels,
                yes:function (index, layerC) {
                    // 子窗口
                    var content 	= layerC.find("iframe")[0].contentWindow;
                    var labels 		= content.$('#has_labels').val();

                    $('#labels').val(labels);
                    $.get("{:U('Label/AdminIndex/get_label_name')}" + "&label_ids=" + labels, {}, function (data) {
                        if (data.status) {
                            $('.label-name').remove();
                            var html = "";
                            $.each(data.data, function (index, item) {
                                html += '<span class="label-name">';
                                html += item.name;
                                html += '</span>';
                            })
                            $('.label-container').append(html);
                        }
                    })

                    layer.close(index);
                }
            });
        });


        /////---------------------
        Wind.use('validate', 'ajaxForm', 'artDialog', function() {

            var form = $('form.js-ajax-forms');
            //ie处理placeholder提交问题
            if ($.browser && $.browser.msie) {
                form.find('[placeholder]').each(function() {
                    var input = $(this);
                    if (input.val() == input.attr('placeholder')) {
                        input.val('');
                    }
                });
            }
            //表单验证开始
            form.validate({
                //是否在敲击键盘时验证
                onkeyup : false,
                //当鼠标掉级时验证
                onclick : false,
                //验证错误
                showErrors : function(errorMap, errorArr) {
                    //errorMap {'name':'错误信息'}
                    //errorArr [{'message':'错误信息',element:({})}]
                    try {
                        $(errorArr[0].element).focus();
                        art.dialog({
                            id : 'error',
                            icon : 'error',
                            lock : true,
                            fixed : true,
                            background : "#CCCCCC",
                            opacity : 0,
                            content : errorArr[0].message,
                            cancelVal : '确定',
                            cancel : function() {
                                $(errorArr[0].element).focus();
                            }
                        });
                    } catch (err) {
                    }
                },
                //验证规则
                rules : {
                    'pf_info[labels]' : {
                        required : 1
                    }
                },
                //验证未通过提示消息
                messages : {
                    'pf_info[labels]' : {
                        required : '请输入选择标签'
                    },
                },
                //给未通过验证的元素加效果,闪烁等
                highlight : false,
                //是否在获取焦点时验证
                onfocusout : false,
                //验证通过，提交表单
                submitHandler : function(forms) {
                    $(forms).ajaxSubmit({
                        url : form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
                        dataType : 'json',
                        beforeSubmit : function(arr, $form, options) {

                        },
                        success : function(data, statusText, xhr, $form) {
                            if (data.status) {
                                setCookie("refersh_time", 1);
                                //添加成功
                                Wind.use("artDialog", function() {
                                    art.dialog({
                                        id : "succeed",
                                        icon : "succeed",
                                        fixed : true,
                                        lock : true,
                                        background : "#CCCCCC",
                                        opacity : 0,
                                        content : data.info,
                                        button : [ {
                                            name : '继续编辑？',
                                            callback : function() {
                                                //reloadPage(window);
                                                return true;
                                            },
                                            focus : true
                                        }, {
                                            name : '返回列表页',
                                            callback : function() {
                                                location = "{:U('AdminProfessor/professor_list')}";
                                                return true;
                                            }
                                        } ]
                                    });
                                });
                            } else {
                                artdialog_alert(data.info);
                            }
                        }
                    });
                }
            });
        });

        function show_detail(title, desc) {
            content = "<div style='width: 400px;height: 300px;'>" + desc + "</div>"
            Wind.use('artDialog', 'artDialog', function () {
                var d = artDialog({
                    title: title,
                    content: content
                });
                d.show();
            });
        }
    </script>
</body>
</html>